package mylittleinvestigations;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;

public class PulseSet
{
    private PulseTrack[] pulseSet;
    private double difRotation=0;
    private int count=0;

    public PulseSet(int difficulty)
    {
        difRotation=(360d/(double)difficulty)/2d;
        pulseSet=new PulseTrack[difficulty];
        count=difficulty;
        for(int i=0;i<count;i++)
        {
            pulseSet[i]=new PulseTrack();
            pulseSet[i].setInitialTheta(Math.PI / 2 + (i % 2 == 1 ? 0 : Math.PI));
        }
    }

    public void setPathImage(Image image)
    {
        for(int i=0;i<count;i++)
        {
            pulseSet[i].setPathImage(image);
        }
    }
    public void setBallImage(Image image)
    {
        for(int i=0;i<count;i++)
        {
            pulseSet[i].setBallImage(image);
        }
    }
    public void update(int delta)
    {
        for(int i=0;i<count;i++)
        {
            pulseSet[i].update(delta);
        }
    }
    public void drawImage(Graphics g)
    {
        for(int i=0;i<count;i++)
        {
            pulseSet[i].drawTrack(g);
        }
        for(int i=0;i<count;i++)
        {
            pulseSet[i].drawBall(g);
        }
    }
    public void setRotation(double rotation)
    {
        for(int i=0;i<count;i++)
        {
            pulseSet[i].setRotation((rotation+(difRotation*(double)i)));
        }
    }
    public void setPosition(double x,double y)
    {
        for(int i=0;i<count;i++)
        {
            pulseSet[i].setPosition(x,y);
        }
    }
    public void setTrackSpeed(double speed)
    {
        for(int i=0;i<count;i++)
        {
            pulseSet[i].setTrackSpeed(((i/2)%2)==1?speed:-speed);
        }
    }
    public void setBallSpeed(double speed)
    {
        for(int i=0;i<count;i++)
        {
            pulseSet[i].setBallSpeed(((i/2)%2)==1?speed:-speed);
        }
    }
}
